package com.itheima.command;

import java.util.ArrayList;

/**
 * @author zzw
 * @date 2025/10/25
 * @description 命令模式（请求者）
 */
public class Waiter {

    // 持有命令对象
    private final ArrayList<Command> commands;

    public Waiter() {
        commands = new ArrayList<>();
    }

    public void setCommand(Command command) {
        commands.add(command);
    }

    // 发出命令
    public void orderUp() {
        System.out.println("叮咚，大厨，新订单来了......");
        for (Command command : commands) {
            if (command != null) {
                command.execute();
            }
        }
    }
}
